package com.blaze.framework.starter.mybatis.plus.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.blaze.framework.core.util.domain.orm.Auditable;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 抽象的审计实体
 * @author created by Zhou Zongbo on 2025/5/30.
 * @param <PK> the type of the identifier
 */
@EqualsAndHashCode(callSuper = true)
@Data
public abstract class AbstractAuditableEntity<PK extends Serializable>
        extends AbstractPersistence<PK> implements Auditable<PK> {
    /**
     * 创建人Id
     */
    @TableField(fill = FieldFill.INSERT)
    private Long createdUserId;

    /**
     * 创建人名称
     */
    @TableField(fill = FieldFill.INSERT)
    private String createdUserName;

    /**
     * 修改人id
     */
    @TableField(fill = FieldFill.INSERT)
    private Long lastModifiedUserId;

    /**
     * 修改人名称
     */
    @TableField(fill = FieldFill.UPDATE)
    private String lastModifiedUserName;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdDate;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastModifiedDate;
}
